﻿@model IEnumerable<DLM.Domain.Model.Message>
@using Webdiyer.WebControls.Mvc;
<script type="text/javascript">

    $(function () {
        $(":checkbox").attr("checked", false);
        /**全选与反选**/
        $("#checkAll").click(function () {
            /**方法1**/
            if ($("#checkAll").attr("checked")) {
                $(":checkbox").attr("checked", true);
            } else {
                $(":checkbox").attr("checked", false);
            }
        });


    });

    function confirmed(id) {
        if (id != null) {
            $.ajax({
                type: "POST",
                url: "/User/ConfirmedMessage",
                data: { id: id }
            }).done(function (msg) {
                $(this).parents("tr").attr("class","");
            });
        }
    }
</script>
<h3>
    私人消息<a>共 @Model.Count() 条</a></h3>
@using (Ajax.BeginForm("DeleteMessage", "User", new AjaxOptions { InsertionMode = InsertionMode.Replace, HttpMethod = "Post", UpdateTargetId = "divMessage" }))
{
    <div class="tr clearfix">
        &nbsp;&nbsp;&nbsp;&nbsp;操作:&nbsp;&nbsp;<input type="submit" value="" class="btn_s delete_message" />
    </div>
    <div class="tr clearfix">
        <table class="tb message_box">
            <thead>
                <tr>
                    <th></th>
                    <th>
                        来自
                    </th>
                    <th>
                        话题
                    </th>
                    <th>
                        时间
                    </th>
                    <th>
                        <input type="checkbox" id="checkAll" />全选
                    </th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model)
                {

                    if (item.IsRead)
                    {
                    <tr class="message_read">
                        <td>
                            <i></i>
                        </td>
                        <td>
                            @item.Source
                        </td>
                        <td>
                            <span class="message_wrap"  >
                                <a href="@Url.Action("MessageView", "User", new { id = item.MessageID })">@item.Title</a></span>
                        </td>
                        <td>
                            @item.CreateDate
                        </td>
                        <td>
                            <input type="checkbox" id="checkedId" name="checkedId" value="@item.MessageID" />
                        </td>
                    </tr>
                    }
                    else
                    { 
                    <tr class="">
                        <td>
                            <i></i>
                        </td>
                        <td>
                            @item.Source
                        </td>
                        <td>
                            <span class="message_wrap"><a onclick="confirmed(@item.MessageID)" href="@Url.Action("MessageView", "User", new { id = item.MessageID })">@item.Title</a></span>
                        </td>
                        <td>
                            @item.CreateDate
                        </td>
                        <td>
                            <input type="checkbox" id="checkedId" name="checkedId" value="@item.MessageID" />
                        </td>
                    </tr>
                    }
@*                       <tr>
                            <td>
                                @item.Source
                            </td>
                            <td>
           
                  
                                <span class="message_wrap"><a onclick="confirmed(@item.MessageID)" href="@Url.Action("MessageView", "User", new { id = item.MessageID })">@item.Title</a></span>
                  
                            </td>
                            <td>
                                                          <a  onclick="confirmed(@item.MessageID)" href="@Url.Action("MessageView", "User", new { id = item.MessageID })">

                                @item.CreateDate
                                </a>
                            </td>
                            <td>
                                <input type="checkbox" id="checkedId" name="checkedId" value="@item.MessageID" />
                            </td>
                        </tr>*@
                  
                }
            </tbody>
        </table>
    </div>
}
<div class="paging">
    @Ajax.Pager(Model as PagedList<DLM.Domain.Model.Message>, new PagerOptions
{
    PageIndexParameterName = "messageid",
    CurrentPagerItemWrapperFormatString = "<span class=\"current\">{0}</span>",
    //NumericPagerItemWrapperFormatString = "<a>{0}</a>",
    PrevPageText = "<",
    NextPageText = ">",
    ShowNumericPagerItems = true,
    ShowFirstLast = false,
    ShowPrevNext = true,
    CssClass = "scott",
    MorePageText = "...",
    SeparatorHtml = ""
},
        new AjaxOptions { UpdateTargetId = "divMessage" }
    )
</div>
